//
//  My_YinJian.m
//  HappyStore
//
//  Created by 点点充 on 16/2/3.
//  Copyright © 2016年 LLJ. All rights reserved.
//

#import "My_YinJian.h"
#import "SearchProjectCell.h"
#import "SearchPriceCell.h"
#import "SearchProjectInfoVC.h"
#import "SearchPriceDetail.h"


//支付头文件
#import "LSBecomeVIPVC.h"
#import "LSRechargeVC.h"
#import "ForgetPassWord.h"
#import "LSPayResultVC.h"


@interface My_YinJian ()
{
    NSMutableArray *muAryInfo;
    NSInteger paggge;
    
    NSMutableDictionary *muDicParameters;
    /********支付*********/
    NSString * or_Number;
    BOOL  isSetPayPass;
    NSString * projectId;
    double price;
    /*******/
}
@property (strong ,nonatomic) NSString *isProjectOrPrice;
@property (strong, nonatomic) LSPromptAlertVC * LSPromptAlert;
@end
static NSString *searchProjectcell = @"SearchProjectCell";
static NSString *searchPricecell = @"SearchPriceCell";
@implementation My_YinJian
- (LSPromptAlertVC *)LSPromptAlert{
    if (!_LSPromptAlert) {
        _LSPromptAlert = [[LSPromptAlertVC alloc] init];
    }
    return _LSPromptAlert;
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    self.tabBarController.tabBar.hidden = YES;
    self.navigationController.navigationBarHidden = NO;
    
    if (muDicParameters == nil) {
        muDicParameters = [NSMutableDictionary dictionary];
        paggge = 1;
        [muDicParameters setObject:[NSString stringWithFormat:@"%ld",paggge] forKey:@"page"];
    }

    [self startSearch];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //设置返回按钮
    UIBarButtonItem *leftItem = [UIBarButtonItem itemWithTarget:self action:@selector(leftBarButtonItemClick) image:@"Back" highImage:@"Back"];
    self.navigationItem.leftBarButtonItem = leftItem;
    
    
    UINib *nib = [UINib nibWithNibName:@"SearchProjectCell" bundle:nil];
    [self.mainTableView registerNib:nib forCellReuseIdentifier:searchProjectcell];
    
    UINib *nib2 = [UINib nibWithNibName:@"SearchPriceCell" bundle:nil];
    [self.mainTableView registerNib:nib2 forCellReuseIdentifier:searchPricecell];
    
    
    
    _mainTableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        if (muAryInfo.count != 0) {
            NSString *path = [[NSBundle mainBundle]pathForResource:@"refresh"
                                                            ofType:@"wav"];
            SystemSoundID soundID;
            AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:path], &soundID);
            AudioServicesPlaySystemSound(soundID); //仅播放音频
            
            paggge = 1;
            [muDicParameters setObject:@"1" forKey:@"page"];
            
            [self startSearch];
        }else {
            [_mainTableView.mj_header endRefreshing];
        }
    }];
    
    
    
    _mainTableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        paggge += 1;
        [muDicParameters setObject:[NSString stringWithFormat:@"%ld",paggge] forKey:@"page"];
        [self startSearch];
    }];
    
    _mainTableView.mj_footer.hidden = YES;
    
    //开启侧滑
    self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
}
-(void)leftBarButtonItemClick{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    [tableView tableViewDisplayWitMsg:@"没有查询到相对应的数据" ifNecessaryForRowCount:muAryInfo.count];
    return muAryInfo.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.MainSegment.selectedSegmentIndex == 0) {//项目
        return 110;
    }else if (self.MainSegment.selectedSegmentIndex == 1){//资金
        return 145;
    }
    return 0;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (self.MainSegment.selectedSegmentIndex == 0) {//项目
        SearchProjectCell *projectCell = [self.mainTableView dequeueReusableCellWithIdentifier:searchProjectcell];
        projectCell.TitleLabel.text = muAryInfo[indexPath.row][@"title"];
        projectCell.AddressLabel.text = muAryInfo[indexPath.row][@"address"];
        
        projectCell.IndustryLabel.text = muAryInfo[indexPath.row][@"industry"];
        
        if ([[CustomExcetion comperNumber:muAryInfo[indexPath.row][@"investment"]] isEqualToString:@"0元"]) {
            projectCell.PriceLabel.text = @"面议";
        }else{
            projectCell.PriceLabel.text = [CustomExcetion comperNumber:muAryInfo[indexPath.row][@"investment"]];
        }
        if ([muAryInfo[indexPath.row][@"type"] isEqualToString:@"政府"]) {
            
            projectCell.ProjectIconImageView.image = [UIImage imageNamed:@"政府"];
        }else if ([muAryInfo[indexPath.row][@"type"] isEqualToString:@"企业"]){
            
            projectCell.ProjectIconImageView.image = [UIImage imageNamed:@"企业"];
        }else{
            
            projectCell.ProjectIconImageView.image = [UIImage imageNamed:@"个人"];
        }
        
        return projectCell;
    }else if(self.MainSegment.selectedSegmentIndex == 1){//资金
        SearchPriceCell *cell = [self.mainTableView dequeueReusableCellWithIdentifier:searchPricecell];
        NSDictionary *dic = muAryInfo[indexPath.row];
        
        //设置圆形头像
        [cell.headPhoto.layer setCornerRadius:cell.headPhoto.frame.size.height/2];
        [cell.headPhoto.layer setMasksToBounds:YES];
        [cell.headPhoto setContentMode:UIViewContentModeScaleAspectFill];
        [cell.headPhoto setClipsToBounds:YES];
        cell.headPhoto.layer.shadowColor = [UIColor blackColor].CGColor;
        cell.headPhoto.layer.shadowOffset = CGSizeMake(4, 4);
        cell.headPhoto.layer.shadowOpacity = 0.5;
        cell.headPhoto.layer.shadowRadius = 2.0;
        cell.headPhoto.userInteractionEnabled = YES;
        
        [cell.headPhoto sd_setImageWithURL:dic[@"headPhoto"] placeholderImage:[UIImage imageNamed:@"20100403114758394_4147"]];
        
        
        
        cell.commentUserName.text = dic[@"username"];
        if (dic[@"username"]==nil || [dic[@"username"] isEqualToString:@""] || [dic[@"username"] isEqualToString:@"null"]) {
            cell.commentUserName.text = dic[@"account"];
        }
        
        
        cell.posiTion.text = dic[@"posiTionName"];
        if (dic[@"posiTionName"]==nil||[dic[@"posiTionName"] isEqualToString:@"null"]) {
            cell.posiTion.text = @"";
        }
        
        
//        if ([dic[@"authState"] integerValue] == 2) {
//            
//            cell.authStateImageView.image = [UIImage imageNamed:@"yirenzheng"];
//        }else{
//            
//            cell.authStateImageView.image = [UIImage imageNamed:@"weirenzheng"];
//        }
        //认证
        cell.isAuthState.hidden = [UsedTool authStateImageViewHidden:dic[@"authState"]];
        //会员图标
        cell.authStateImageView.image = [UsedTool setVipimage:dic[@"vipLevel"]];
        cell.titleLabel.text = dic[@"title"];
        
        cell.priceLabel.text = [CustomExcetion comperNumber:dic[@"investment"]];
        
        
        
        //判断上级
        cell.companyUserName.text = [UsedTool userType:dic[@"userType"] companyName:dic[@"companyName"] userAddress:dic[@"userAddress"]];
        return cell;
    }
    
    return nil;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];//取消选中状态
    
    //取消显示后退键文字
    UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleDone target:nil action:nil];
    self.navigationItem.backBarButtonItem = barButtonItem;
    if (self.MainSegment.selectedSegmentIndex == 0) {
        //项目
        self.isProjectOrPrice = @"项目";
        [self clickForDetails:muAryInfo[indexPath.row][@"projectId"]];
//        SearchProjectInfoVC *projectVC = [[SearchProjectInfoVC alloc] init];
//        projectVC.projectId = muAryInfo[indexPath.row][@"projectId"];
//        [self.navigationController pushViewController:projectVC animated:YES];

    }else {
        //资金
        self.isProjectOrPrice = @"资金";
        [self clickForDetails:muAryInfo[indexPath.row][@"fundsId"]];
//        SearchPriceDetail *priceVC = [[SearchPriceDetail alloc] init];
//        priceVC.fundsId = muAryInfo[indexPath.row][@"fundsId"];
//        [self.navigationController pushViewController:priceVC animated:YES];

    }
    

}


- (void)startSearch
{
    muAryInfo = nil;
    //token=验证用户&userId=用户id&page=页码&type=类型（1 投递 2邀请）
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
    
    NSString *strURl;
    
    if (self.MainSegment.selectedSegmentIndex == 0) {
        //项目
        strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getReferralplatform_app_myHome.im.lensum"];
    }else {
        //资金
        strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getReferralplatform_funds_app_myHome.im.lensum"];
    }
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    [manager POST:strURl parameters:muDicParameters progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
        NSLog(@"%@",dicInfo);
        if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
            
            if (paggge == 1) {
                [_mainTableView.mj_header endRefreshing];
                
                muAryInfo = [NSMutableArray arrayWithArray:[dicInfo objectForKey:@"data"][@"record"]];
                
                if (muAryInfo.count == 10) {
                    _mainTableView.mj_footer.hidden = NO;
                }else {
                    _mainTableView.mj_footer.hidden = YES;
                }
                
            }else {
                [_mainTableView.mj_footer endRefreshing];
                NSArray *ary11 = [dicInfo objectForKey:@"data"][@"record"];
                for (int i = 0; i<ary11.count; i++) {
                    NSDictionary *dic1 = ary11[i];
                    [muAryInfo addObject:dic1];
                }
                if (ary11.count == 10) {
                    _mainTableView.mj_footer.hidden = NO;
                }else {
                    _mainTableView.mj_footer.hidden = YES;
                }
                
            }
            
            
            [_mainTableView reloadData];

        }else {
            [_mainTableView reloadData];
            [_mainTableView.mj_header endRefreshing];
            [_mainTableView.mj_footer endRefreshing];

        }
        
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        [_mainTableView.mj_header endRefreshing];
        [_mainTableView.mj_footer endRefreshing];

        [self showSingleIconBubble:error.localizedDescription];

    }];
}

#pragma mark -选择类型
- (IBAction)btnClickSegmented:(UISegmentedControl *)sender
{
    [muDicParameters setObject:@"1" forKey:@"page"];

    [self startSearch];
}


#pragma mark - ＊＊＊＊＊支付＊＊＊＊＊
//点击查看详细（项目or资金）
- (void)clickForDetails:(NSString *)resId{
    if (allConstMemberid) {
        [self showRoundProgressWithTitle:@"请稍后..."];
        
        NSMutableDictionary * dict = [NSMutableDictionary dictionary];
        NSString *strData = @"";
        if ([self.isProjectOrPrice isEqualToString:@"项目"]){
            dict[@"projectId"] = resId;
            strData = @"projectDetail_app_project.im";
        }else if ([self.isProjectOrPrice isEqualToString:@"资金"]){
            dict[@"fundsId"] = resId;
            strData = @"fundsDetail_app_funds.im";
        }else{}
        
        if ([USER_DEFAULTS objectForKey:@"userid"] != nil) {
            dict[@"userId"] = [USER_DEFAULTS objectForKey:@"userid"];
        }
        
        
        
        [LSHttpTool sendHttpData:strData params:dict success:^(id responseObject) {
            NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
            
            if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
                
                [self.LSPromptAlert dismissViewControllerAnimated:YES completion:nil];
                if ([self.isProjectOrPrice isEqualToString:@"项目"]) {//项目
                    SearchProjectInfoVC * SeaVC = [[SearchProjectInfoVC alloc]initWithNibName:@"SearchProjectInfoVC" bundle:nil];
                    SeaVC.dataDict = dicInfo[@"data"];
                    SeaVC.projectData = [NSMutableArray arrayWithArray:dicInfo[@"data"][@"commentsList"]];
                    
                    [self.navigationController pushViewController:SeaVC animated:YES];
                }else if([self.isProjectOrPrice isEqualToString:@"资金"]){//资金
                    SearchPriceDetail *Svc = [[SearchPriceDetail alloc] initWithNibName:@"SearchPriceDetail" bundle:nil];
                    
                    Svc.dicData = dicInfo[@"data"];
                    Svc.commentsList = dicInfo[@"data"][@"commentsList"];
                    
                    [self.navigationController pushViewController:Svc animated:YES];
                }else{
                }
                
                
            }else if ([[dicInfo objectForKey:@"result"] integerValue] == 2){

                [self showSingleIconBubble:[dicInfo objectForKey:@"msg"]];
                
            }else if ([[dicInfo objectForKey:@"result"]integerValue] == 3){
                
                isSetPayPass = [dicInfo[@"data"][@"isSetPayPass"] boolValue];
                price = [dicInfo[@"data"][@"powerMoney"]floatValue];
                
                projectId = resId;
                self.LSPromptAlert.modalPresentationStyle=UIModalPresentationOverCurrentContext;
                [self presentViewController:self.LSPromptAlert animated:YES completion:nil];
                
            }
            
            [self hideBubble];
        } failure:^(NSError *error) {

            [self showSingleIconBubble:@"网络连接错误"];
            
        }];
        
    }else{
        
        UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示" message:@"请先登录" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"登录", nil];
        
        alert.tag = 10;
        
        [alert show];
        
    }
    
}


#pragma mark - 弹框按钮监听
//跳转会员界面
-(void)clickBecomeVIPBtn{
    
    [self.LSPromptAlert dismissViewControllerAnimated:YES completion:nil];
    
    LSBecomeVIPVC * LSBecomeVIP = [[LSBecomeVIPVC alloc]init];
    [self.navigationController pushViewController:LSBecomeVIP animated:YES];
    
}


#pragma mark - 支付回调通知
-(void)clickAlipayBtn{
    if ([self.isProjectOrPrice isEqualToString:@"项目"]) {
        or_Number = [LSAlipay alipay:@"乐商网" body:@"项目详情" price:0.01f];
    }else if([self.isProjectOrPrice isEqualToString:@"资金"]){
        or_Number = [LSAlipay alipay:@"乐商网" body:@"资金详情" price:0.01f];
    }else{
        or_Number = nil;
    }
}

-(void)presentFailedView{
    
    // 跳转至支付失败页面
    LSPayResultVC * LSPayResult = [[LSPayResultVC alloc]init];
    [LSPayResult setCashTypeWithCashFailed];
    [self.navigationController pushViewController:LSPayResult animated:YES];
    
}

-(void)presentView{
    
    [self.LSPromptAlert dismissViewControllerAnimated:YES completion:nil];
    [self showRoundProgressWithTitle:@"请稍后..."];
    
    NSMutableDictionary * dic = [NSMutableDictionary  dictionary];
    dic[@"token"] = allConstMemberToken;
    dic[@"payUserId"] = allConstMemberid;
    dic[@"payWay"] = @"2";
    dic[@"payMoney"] = @(price);
    dic[@"resId"] = projectId;
    dic[@"order_no"] = or_Number;
    NSString *strData = @"";
    if ([self.isProjectOrPrice isEqualToString:@"项目"]) {
        strData = @"buyProjectDetail_app_pay.im.lensum";
    }else if([self.isProjectOrPrice isEqualToString:@"资金"]){
        strData = @"buyFundsDetail_app_pay.im.lensum";
    }else{
        strData = @"";
    }
    
    [LSHttpTool sendHttpData:strData params:dic success:^(id responseObject) {
        
        NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
        
        [self.LSPromptAlert dismissViewControllerAnimated:YES completion:nil];
        
        if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
            
            NSMutableDictionary * dict = [NSMutableDictionary dictionary];
            if ([self.isProjectOrPrice isEqualToString:@"项目"]) {
                dict[@"projectId"] = dic[@"resId"];
            }else if([self.isProjectOrPrice isEqualToString:@"资金"]){
                dict[@"fundsId"] = dic[@"resId"];
            }
            if ([USER_DEFAULTS objectForKey:@"userid"] != nil) {
                dict[@"userId"] = [USER_DEFAULTS objectForKey:@"userid"];
            }
            NSString *dataStr = @"";
            if ([self.isProjectOrPrice isEqualToString:@"项目"]) {
                dataStr = @"projectDetail_app_project.im";
            }else if ([self.isProjectOrPrice isEqualToString:@"资金"]){
                dataStr = @"fundsDetail_app_funds.im";
            }else{
                dataStr = @"";
            }
            [LSHttpTool sendHttpData:dataStr params:dict success:^(id responseObject) {
                if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
                    if ([self.isProjectOrPrice isEqualToString:@"项目"]) {
                        SearchProjectInfoVC * SeaVC = [[SearchProjectInfoVC alloc]initWithNibName:@"SearchProjectInfoVC" bundle:nil];
                        SeaVC.dataDict = responseObject[@"data"];
                        SeaVC.projectData = [NSMutableArray arrayWithArray:responseObject[@"data"][@"commentsList"]];
                        
                        [self.navigationController pushViewController:SeaVC animated:YES];
                    }else if([self.isProjectOrPrice isEqualToString:@"资金"]){
                        SearchPriceDetail *Svc = [[SearchPriceDetail alloc] initWithNibName:@"SearchPriceDetail" bundle:nil];
                        
                        Svc.dicData = responseObject[@"data"];
                        Svc.commentsList = responseObject[@"data"][@"commentsList"];
                        [self.navigationController pushViewController:Svc animated:YES];
                    }else{}
                    
                    
                    [self hideBubble];
                    
                }else{

                    [self showSingleIconBubble:[responseObject objectForKey:@"msg"]];
                    
                }
                
            } failure:^(NSError *error) {

                [self showErrorWithTitle:@"网络错误" autoCloseTime:2];
                
            }];
            
        }else{

            [self showSingleIconBubble:[dicInfo objectForKey:@"msg"]];
            
        }
        
    } failure:^(NSError *error) {
        
        // 跳转至支付成功页面
        LSPayResultVC * LSPayResult = [[LSPayResultVC alloc]init];
        [LSPayResult setCashTypeWithExchangeFailed];
        
        [self hideBubble];
    }];
    
}

#pragma mark - 余额支付
-(void)clickCashBtn{
    
    NSString * balanceStr = [self.LSPromptAlert.PromptAlertView.balanceLabel.text stringByReplacingOccurrencesOfString:@"￥"withString:@""];
    
    double balance = [balanceStr floatValue];
    
    if (balance < 1) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"支付失败"
                                                        message:@"余额不足！"
                                                       delegate:self
                                              cancelButtonTitle:@"取消"
                                              otherButtonTitles:@"立刻充值",nil];
        alert.tag = 20;
        [alert show];
        
    }else{
        
        if (isSetPayPass) {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"支付失败"
                                                            message:@"未设置支付密码"
                                                           delegate:self
                                                  cancelButtonTitle:@"取消"
                                                  otherButtonTitles:@"立即设置",nil];
            alert.tag = 30;
            [alert show];
            
        }else{
            
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"余额支付" message:nil delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];
            alert.alertViewStyle = UIAlertViewStylePlainTextInput;
            
            UITextField *title = [alert textFieldAtIndex:0];
            [title setSecureTextEntry:YES];
            title.borderStyle = UITextBorderStyleNone;
            title.textColor = [UIColor redColor];
            title.textAlignment = NSTextAlignmentCenter;
            title.font = [UIFont systemFontOfSize:16.0f];
            title.placeholder = @"请输入支付密码";
            
            
            [alert showAlertWithCompletionHandler:^(NSInteger buttonIndex) {
                if(buttonIndex == 1){
                    UITextField *tf=[alert textFieldAtIndex:0];
                    if (tf.text.length > 0) {
                        
                        [self showRoundProgressWithTitle:@"请稍后..."];
                        
                        NSMutableDictionary * dic = [NSMutableDictionary  dictionary];
                        dic[@"token"] = allConstMemberToken;
                        dic[@"payUserId"] = allConstMemberid;
                        dic[@"payWay"] = @"1";
                        dic[@"payMoney"] = @(price);
                        dic[@"resId"] = projectId;
                        dic[@"payPass"] = tf.text;
                        NSString *strData = @"";
                        if ([self.isProjectOrPrice isEqualToString:@"项目"]) {
                            strData = @"buyProjectDetail_app_pay.im.lensum";
                        }else if([self.isProjectOrPrice isEqualToString:@"资金"]){
                            strData = @"buyFundsDetail_app_pay.im.lensum";
                        }else{}
                        [LSHttpTool sendHttpData:strData params:dic success:^(id responseObject) {
                            
                            [self.LSPromptAlert dismissViewControllerAnimated:YES completion:nil];
                            
                            NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
                            if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
                                
                                NSMutableDictionary * dict = [NSMutableDictionary dictionary];
                                if ([self.isProjectOrPrice isEqualToString:@"项目"]) {
                                    dict[@"projectId"] = dic[@"resId"];
                                }else if ([self.isProjectOrPrice isEqualToString:@"资金"]){
                                    dict[@"fundsId"] = dic[@"resId"];
                                }else{}
                                if ([USER_DEFAULTS objectForKey:@"userid"] != nil) {
                                    dict[@"userId"] = [USER_DEFAULTS objectForKey:@"userid"];
                                }
                                
                                NSString *dataStr = @"";
                                if ([self.isProjectOrPrice isEqualToString:@"项目"]) {
                                    dataStr = @"projectDetail_app_project.im";
                                }else if([self.isProjectOrPrice isEqualToString:@"资金"]){
                                    dataStr = @"fundsDetail_app_funds.im";
                                }else{}
                                [LSHttpTool sendHttpData:dataStr params:dict success:^(id responseObject) {
                                    if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
                                        if ([self.isProjectOrPrice isEqualToString:@"项目"]) {
                                            SearchProjectInfoVC * SeaVC = [[SearchProjectInfoVC alloc]initWithNibName:@"SearchProjectInfoVC" bundle:nil];
                                            SeaVC.dataDict = responseObject[@"data"];
                                            SeaVC.projectData = [NSMutableArray arrayWithArray:responseObject[@"data"][@"commentsList"]];
                                            
                                            [self.navigationController pushViewController:SeaVC animated:YES];
                                        }else if ([self.isProjectOrPrice isEqualToString:@"资金"]){
                                            SearchPriceDetail *Svc = [[SearchPriceDetail alloc] initWithNibName:@"SearchPriceDetail" bundle:nil];
                                            
                                            Svc.dicData = responseObject[@"data"];
                                            Svc.commentsList = responseObject[@"data"][@"commentsList"];
                                            [self.navigationController pushViewController:Svc animated:YES];
                                        }else{}
                                        [self hideBubble];
                                        
                                    }else{

                                        [self showSingleIconBubble:[responseObject objectForKey:@"msg"]];
                                        
                                    }
                                    
                                } failure:^(NSError *error) {

                                    [self showSingleIconBubble:@"网络连接错误"];
                                    
                                }];
                                
                            }else{

                                [self showSingleIconBubble:[dicInfo objectForKey:@"msg"]];
                                
                            }
                            
                            
                        } failure:^(NSError *error) {
                            
                            // 跳转至支付成功页面
                            LSPayResultVC * LSPayResult = [[LSPayResultVC alloc]init];
                            [LSPayResult setCashTypeWithCashFailed];

                            [self hideBubble];
                        }];
                        
                    }else{
                        
                        NSString *strMsg = @"密码不能为空";
                        
                        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:strMsg delegate:self cancelButtonTitle:@"知道了" otherButtonTitles:nil, nil];
                        [alert show];
                        
                    }
                }
            }];
            
            
        }
        
    }
    
}

#pragma mark - alertview

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (buttonIndex == 1) {
        [self.LSPromptAlert dismissViewControllerAnimated:YES completion:nil];
        
        UIStoryboard *LoginAndRegister = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        UINavigationController *loginNAV = [LoginAndRegister instantiateViewControllerWithIdentifier:@"LoginNav"];
        //充值
        LSRechargeVC * LSRecharge = [[LSRechargeVC alloc]init];
        
        switch (alertView.tag) {
            case 10:
                
                [self presentViewController:loginNAV animated:YES completion:nil];
                
                break;
                
            case 20:
                
                [self.navigationController pushViewController:LSRecharge animated:YES];
                
                break;
                
            case 30:
            {
                
                UIStoryboard *LoginAndRegister = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
                ForgetPassWord *ForgetPassWord = [LoginAndRegister instantiateViewControllerWithIdentifier:@"forgetpassword"];
                ForgetPassWord.titleStr = @"修改支付密码";
                [self.navigationController pushViewController:ForgetPassWord animated:YES];
                
            }
                break;
                
            default:
                break;
        }
    }
    
    
}





@end
